<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link href="css/primer.css" rel="stylesheet" />
  <link rel="stylesheet" href="css/basic.css" />
  <title>EZBabyCTF</title>
  <script src="Js/md5.js"></script>
  <script src="http://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
  <!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"
    integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> -->
  <script src="Js/core.js"></script>
  <script src="Js/tpef.js"></script>
  <script src="Js/mask.js"></script>
</head>

<body>
  <div class="Header" style="background-color: rgba(0, 0, 0, 0.826)">
    <div class="Header-item m-auto">
      <span id="Head">EZBabyCTF</span>
    </div>
    <div class="Header-item m-3 logon">
      <span class="Header-link" id="amin">出题</span>
    </div>
    <div class="Header-item m-3">
      <span class="Header-link" id="notif">通知 </span>
    </div>
    <div class="Header-item m-3">
      <span class="Header-link" id="team">战队</span>
    </div>
    <div class="Header-item m-3">
      <span class="Header-link" onclick="showboard()">排行榜</span>
    </div>
    <div class="Header-item m-3 logout">
      <span class="Header-link" onclick="signp()">注册</span>
    </div>
    <div class="Header-item m-3 logout">
      <span class="Header-link" onclick="signi()">登录</span>
    </div>
    <div class="Header-item m-3 logon">
      <span class="Header-link" id="chapas">修改密码</span>
    </div>
    <div class="Header-item m-3 logon">
      <span class="Header-link" id="signo">登出</span>
    </div>
  </div>
  <div class="marsk-container"></div>

  <div class="p-1 pophint" id="truehint">
    <div class="Toast Toast--success">
      <span class="Toast-icon">
        <!-- <%= octicon "check" %> -->
        <svg width="12" height="16" viewBox="0 0 12 16" class="octicon octicon-check" aria-hidden="true">
          <path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z" />
        </svg>
      </span>
      <span class="Toast-content">太牛了！给你鼓掌👏👏</span>
    </div>
  </div>
  <div class="p-1 pophint" id="falsehint">
    <div class="Toast Toast--error">
      <span class="Toast-icon">
        <!-- <%= octicon "stop" %> -->
        <svg width="14" height="16" viewBox="0 0 14 16" class="octicon octicon-stop" aria-hidden="true">
          <path fill-rule="evenodd"
            d="M10 1H4L0 5v6l4 4h6l4-4V5l-4-4zm3 9.5L9.5 14h-5L1 10.5v-5L4.5 2h5L13 5.5v5zM6 4h2v5H6V4zm0 6h2v2H6v-2z" />
        </svg>
      </span>
      <span class="Toast-content">Oh No 再想想吧</span>
    </div>
  </div>

  <div id="challengefather">
    <div class="mt-3 p-5 anim-fade-in" id="chllfa">
      <!-- <button class="btn-mktg btn-transparent enlarge m-2" type="button" style="position: relative">
        <div class="challengeid"></div>
        <div class="challengename">CandyShop</div>
        <div class="challengedisc">
          题目描述：这是一段题目描述我需要知道它最多能写下多少字这是一段哈哈哈哈题目描述我需要知道它最多能写下多少字这是一段56个字
        </div>
        <span class="score">1000</span>
        <div class="chtype">Web</div>
        <div class="submitflagfather">
          <input class="form-control submitflag" type="text" placeholder="flag{xxxxxxx}" />
          <span class="Box-btn-octicon btn-octicon submittingbtn" type="button"><svg class="octicon octicon-x"
              xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
              <path fill-rule="evenodd"
                d="M8.53 1.22a.75.75 0 00-1.06 0L3.72 4.97a.75.75 0 001.06 1.06l2.47-2.47v6.69a.75.75 0 001.5 0V3.56l2.47 2.47a.75.75 0 101.06-1.06L8.53 1.22zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z">
              </path>
            </svg></span>
        </div>
      </button> -->
    </div>
  </div>
  <!-- 以下是弹窗 -->
  <div class="popwindow" id="signup">
    <div class="Box Box--overlay d-flex flex-column anim-fade-in fast" style="width: 600px; height: 500px">
      <div class="Box-header">
        <button class="Box-btn-octicon btn-octicon float-right" type="button" onclick="closesign()">
          <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16">
            <path fill-rule="evenodd"
              d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z">
            </path>
          </svg>
        </button>
        <h3 class="Box-title">EZBabyCTF注册</h3>
      </div>
      <div class="overflow-hidden" style="height: 50vh">
        <div class="Box-body overflow-y-auto type-js" id="signuptyping" style="height: 94%">
          <p class="text-js">
            >嗨，你好(鞠躬)。欢迎来到EZBabyCTF！下面请介绍一下你自己！输入您的用户名：
          </p>
          <p></p>
        </div>
      </div>
      <div class="Box-footer">
        <input type="text" class="form-control" style="width: 95%; margin: 2vh" id="signupipt" />
        <button type="button" class="btn btn-block push">确定</button>
      </div>
    </div>
  </div>
  <div class="popwindow" id="signin">
    <div class="Box Box--overlay d-flex flex-column anim-fade-in fast" style="width: 600px; height: 500px">
      <div class="Box-header">
        <button class="Box-btn-octicon btn-octicon float-right" type="button" onclick="closesign()">
          <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16">
            <path fill-rule="evenodd"
              d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z">
            </path>
          </svg>
        </button>
        <h3 class="Box-title">EZBabyCTF登录</h3>
      </div>
      <div class="overflow-hidden type-father" style="height: 50vh">
        <div class="Box-body overflow-y-auto type-js" id="signintyping" style="height: 94%">
          <p class="text-js">>欢迎回来！输入您的用户名：</p>
          <p></p>
        </div>
      </div>
      <div class="Box-footer">
        <input type="text" class="form-control" style="width: 95%; margin: 2vh" id="signinipt" />
        <button type="button" class="btn btn-block push">确定</button>
      </div>
    </div>
  </div>
  <div class="popwindow" id="changepass">
    <div class="Box Box--overlay d-flex flex-column anim-fade-in fast" style="width: 600px; height: 500px">
      <div class="Box-header">
        <button class="Box-btn-octicon btn-octicon float-right" type="button" onclick="closesign()">
          <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16">
            <path fill-rule="evenodd"
              d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z">
            </path>
          </svg>
        </button>
        <h3 class="Box-title">EZBabyCTF修改密码</h3>
      </div>
      <div class="overflow-hidden type-father" style="height: 50vh">
        <div class="Box-body overflow-y-auto type-js" id="changepasstyping" style="height: 94%">
          <p class="text-js">>又见面了！打算把密码改成什么呀</p>
          <p></p>
        </div>
      </div>
      <div class="Box-footer">
        <input type="text" class="form-control" style="width: 95%; margin: 2vh" id="changepassipt" />
        <button type="button" class="btn btn-block push">确定</button>
      </div>
    </div>
  </div>
  <div class="popwindow" id="scoreboard">
    <div class="Box Box--overlay d-flex flex-column anim-fade-in fast" style="width: 600px; height: 500px">
      <div class="Box-header">
        <button class="Box-btn-octicon btn-octicon float-right" type="button" onclick="closesign()">
          <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16">
            <path fill-rule="evenodd"
              d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z">
            </path>
          </svg>
        </button>
        <h3 class="Box-title">EZBabyCTF排行榜</h3>
      </div>
      <div class="Box-body" id="board"></div>
    </div>
  </div>
  <script>
    $(document).ready(function () {
      $(".marsk-container").click(function () {
        $(".marsk-container").hide();
        $(".popwindow").hide();
        $(".pophint").hide()
      })

    })
    $(document).ready(function () {
      var flag = 0;
      $(".push").click(function push() {
        $(".push").attr("disabled", "disabled");
        if (($("#signin").css("display") == "none") && ($("#signup").css("display") == "none")) {
          var doing = "#changepassipt";
          if (flag < 100 || flag > 104) {
            window.alert('error:2');
            return;
          }
        }
        else if (($("#signup").css("display") == "none") && ($("#changepass").css("display") == "none")) {
          var doing = "#signinipt";
          if (flag < 10) {
            flag = 10;
          }
        }
        else if (($("#signin").css("display") == "none") && ($("#changepass").css("display") == "none")) {
          var doing = "#signupipt";
          if (flag > 9) {
            flag = 0;
          }
        }
        var app = $(doing).val();
        var toappd = $(doing).parent().parent().find(".text-js");
        toappd.append("<p>>" + app + "<p/>");
        flag++;
        var ret = {
          content: "",
          flag: 0
        };
        director(app, flag, ret);
        setTimeout(function () {
          toappd.removeAttr("class");
          toappd.append("<p class='text-js'>>" + ret.content + "<p/>");
          flag = ret.flag;
          typing(doing, 4000);
        }, 1000);
        $(doing).val("");
        setTimeout(() => {
          if (flag == 12) {

            window.location.reload();

          }
        }, 3000);

      });
      $.ajax({
        url: "show_challenges.php",
        type: "GET",
        async: false,
        dataType: "json",
        success: function (challinfo) {
          var toappdf = $("#chllfa");
          $.each(challinfo, function (m1, m2) {
            toappdf.append('<button class="btn-mktg btn-transparent enlarge m-2" type="button" style="position: relative" id="' + m2[1] + '"></button>');
            var newch = $("#" + m2[1]);
            newch.append('<div class="challengeid">' + m2[0] + '</div>');
            newch.append('<div class="challengename">' + m2[1] + '</div>');
            newch.append('<div class="chtype">' + m2[2] + '</div>');
            newch.append('<div class="challengedisc">题目描述：' + m2[3] + '</div>');
            newch.append('<span class="score">' + m2[4] + '</span>');
            newch.attr("zipherf", "" + m2[5]);
            newch.append('<div class="submitflagfather"><input class="form-control submitflag" type="text" placeholder="flag{xxxxxxx}" /><span class="Box-btn-octicon btn-octicon submittingbtn" type="button"><svg class="octicon octicon-x"xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8.53 1.22a.75.75 0 00-1.06 0L3.72 4.97a.75.75 0 001.06 1.06l2.47-2.47v6.69a.75.75 0 001.5 0V3.56l2.47 2.47a.75.75 0 101.06-1.06L8.53 1.22zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"></path></svg></span> </div>')
          })
        }

      })

      if ($.cookie("salt") != undefined) {
        var id = $.cookie("salt").substring(0, 32);
        $.ajax({
          url: "show_done.php",
          async: false,
          data: {
            id: id
          },
          dataType: "json",
          type: "POST",
          success: function (challdone) {
            $.each(challdone, function (m1, m2) {
              $("#" + m2).addClass("successhps");
            })
          }
        });
      }
      $(".submittingbtn").click(function () {

        var chatosb = $(this).parent().parent();
        var chtype = chatosb.find(".chtype").text();
        var chname = chatosb.find(".challengename").text();
        var tmp = chatosb.find(".challengename");
        var coie = $.cookie("salt");
        var ipt = chatosb.find(".submitflag");
        var tosb = ipt.val();
        if (coie == undefined) {
          window.alert("请先登录！");
        } else {
          var id = coie.substring(0, 32);
          $.ajax({
            url: "flag.php",
            type: "POST",
            async: false,
            data: {
              id: id,
              chall_name: chname,
              flag: tosb
            },
            success: function (response) {
              if (response == 'right') {
                submitFlag(1);
              }
              else if (response=='you have done this challenges') {
                window.alert("你已经做过这个题目了！");
              }
              else {
                submitFlag(0);
              }
            }
          })
        }
      });
      console.log($.cookie("salt"));
      if ($.cookie("salt") != undefined) {
        var date = new Date();
        var now = date.getTime();
        var code = $.cookie("salt");
        if (Number(code.substring(32)) <= now) {
          flag = 100;
          $(".logon").show();
        }
        else {
          $(".logout").show();
        }

      }
      else {
        $(".logout").show();
      }
      $("#signo").click(function () {
        if (flag != 100) {
          window.alert("请先登录！");
          return;
        }
        else {
          $.removeCookie('salt');
          window.location.reload();
        }

      })
      $("#chapas").click(function () {
        if (flag != 100) {
          window.alert("请先登录！");
          return;
        }
        $("#changepass").show();
        nedmsak();
        typing("#changepassipt", 2000);

      })
      $("#team").click(function () {
        if (flag != 100) {
          window.alert("请先登录！");
          return;
        }
        window.location.href = "teams.html";

      })
      $("#notif").click(function () {
        if (flag != 100) {
          window.alert("请先登录！");
          return;
        }
        window.location.href = "notifications.html";

      })
      $("#amin").click(function () {
        if (flag != 100) {
          window.alert("请先登录！");
          return;
        }
        window.location.href = "admin.html";
      })
      $(".challengedisc").click(function () {
        var chtype = $(this).parent().find(".chtype").text();
        var chname = $(this).parent().find(".challengename").text();
        var tmp = $(this).parent().find(".challengename");
        var coie = $.cookie("salt");
        var dis = $(this).parent().find(".challengedisc");
        var ipt = $(this).parent().find(".submitflag");
        var todload = $(this).parent().attr("zipherf");
        if (coie == undefined) {
          window.alert("请先登录！");
        } else {
          if (chtype == 'Web') {
            $.ajax({
              url: "open_docker.php",
              type: "POST",
              data: {
                chall_type: chtype,
                chall_name: chname,
                user_id: coie.substring(0, 32)
              },
              dataType: "json",
              success: function (response) {
                tmp.text(chname);
                ipt.attr("value", response[0]);
                $.cookie('name1', response[2]);
                $.cookie('name2', response[1]);
                $.ajax({
                  url: "pyapi.php",
                  type: "GET",
                  data: {
                    arg1: response[1],
                    arg2: response[2]
                  }
                });
                window.open(response[0]);
              },
              error: function () {
                tmp.text(chname);
              }
            })
            tmp.text("Loading……");
          }
          if (chtype == 'Misc' || chtype == 'Re') {
            window.open(todload);
          }
        }

      })
    });
    function signp() {
      $("#signup").show();
      nedmsak();
      typing("#signupipt", 4600);
    }
    function signi() {
      $("#signin").show();
      nedmsak();
      typing("#signinipt", 2000);
    }
    function showboard() {
      $("#scoreboard").show();
      nedmsak();
      $.ajax({
        url: "scoreboard.php",
        type: "GET",
        async: false,
        dataType: "json",
        success: function (response) {
          var toappdf = $("#board");
          $.each(response, function (m1, m2) {
            console.log(m2[0], m2[1]);
            toappdf.append('<div class="Box-row"><span class="tname">' + m2[0] + ' </span><span class="tscore">' + m2[1] + ' </span></div>');
          })
        }
      })
    }
  </script>
  <!-- var id = $(this).attr("id") + "ipt"; if ($("#" + id)) submitFlag($("#" +
id).val()); -->
</body>

</html>
<!-- flag状态：
  0：注册初始状态
  1：注册用户名
  2：注册密码
  3：确认密码
  10：登录初始态
  11：登录用户名
  12：登录密码
  100：登陆成功
  101：修改密码
  102: 确认旧密码
  103：确认新密码

      <button class="btn-mktg btn-transparent enlarge m-2" type="button" style="position: relative">
        <div class="challengeid"></div>
        <div class="challengename">CandyShop</div>
        <div class="challengedisc">
          题目描述：这是一段题目描述我需要知道它最多能写下多少字这是一段哈哈哈哈题目描述我需要知道它最多能写下多少字这是一段56个字
        </div>
        <span class="score">1000</span>
        <div class="chtype">Web</div>
        <div class="submitflagfather">
          <input class="form-control submitflag" type="text" placeholder="flag{xxxxxxx}" />
          <span class="Box-btn-octicon btn-octicon submittingbtn" type="button"><svg class="octicon octicon-x"
              xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
              <path fill-rule="evenodd"
                d="M8.53 1.22a.75.75 0 00-1.06 0L3.72 4.97a.75.75 0 001.06 1.06l2.47-2.47v6.69a.75.75 0 001.5 0V3.56l2.47 2.47a.75.75 0 101.06-1.06L8.53 1.22zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z">
              </path>
            </svg></span>
        </div>
      </button>
 -->